(function(){var e=window.BX;e.namespace("BX.UI");if(!!e.UI.Selector.Callback){return}e.UI.Selector.Callback=function(){};e.UI.Selector.Callback.select=function(t){var n=t.fieldName,i=t.item,a=t.selectorId,l=t.entityType,s=t.undeletable;if(!a||!e.type.isNotEmptyObject(i)||!e.type.isNotEmptyString(l)){return}var o=e.UI.SelectorManager.instances[a];if(!e.type.isNotEmptyObject(o)){return}if(o.nodes.inputItemsContainer&&!e.findChild(o.nodes.inputItemsContainer,{attr:{"data-id":i.id}},false,false)){if(o.getOption("multiple")!="Y"){e.cleanNode(o.nodes.inputItemsContainer);if(o.nodes.input){o.nodes.input.style.display="none"}}var r=e.create("span",{attrs:{"data-id":i.id,"data-type":l},props:{className:o.getRenderInstance().class.itemDestination+" "+o.getRenderInstance().class.itemDestinationPrefix+l.toLowerCase()+" "+(s?" "+o.getRenderInstance().class.itemDestinationUndeletable:"")},children:e.util.array_merge(e.UI.Selector.Callback.getHiddenInputCollection({entityType:l,itemId:i.id,fieldName:o.fieldName,multiple:o.getOption("multiple")=="Y"}),[e.create("SPAN",{props:{className:o.getRenderInstance().class.itemDestinationText},html:i.name+(e.type.isNotEmptyString(i.showEmail)&&i.showEmail=="Y"&&e.type.isNotEmptyString(t.item.email)?" ("+t.item.email+")":"")})])});if(!s){r.appendChild(e.create("SPAN",{props:{className:o.getRenderInstance().class.itemDestinationDeleteButton},events:{click:function(e){o.getRenderInstance().deleteItem({entityType:l,itemId:i.id});e.preventDefault()},mouseover:function(e){e.currentTarget.parentNode.classList.add(o.getRenderInstance().class.itemDestinationHover)},mouseout:function(e){e.currentTarget.parentNode.classList.remove(o.getRenderInstance().class.itemDestinationHover)}}}))}o.nodes.inputItemsContainer.appendChild(r)}if(o.nodes.input){o.nodes.input.value=""}if(o.getOption("multiple")=="Y"){o.setTagTitle()}else{if(o.nodes.tag){e.style(o.nodes.tag,"display","none")}o.closeDialog()}e.onCustomEvent("BX.UI.Selector.Callback:select",[{selectorId:o.id}])};e.UI.Selector.Callback.unSelect=function(t){var n=t.item,i=t.selectorId,a=t.entityType;if(!i||!e.type.isNotEmptyObject(n)||!e.type.isNotEmptyString(a)){return}var l=e.UI.SelectorManager.instances[i];if(!e.type.isNotEmptyObject(l)){return}delete l.itemsSelected[n.id];if(l.nodes.inputItemsContainer){var s=e.findChildren(l.nodes.inputItemsContainer,{attribute:{"data-id":""+n.id+""}},true);if(s!==null){for(var o=0;o<s.length;o++){if(!e.hasClass(s[o],l.getRenderInstance().class.itemDestinationUndeletable)){e.remove(s[o])}}}}if(l.nodes.input){l.nodes.input.value=""}l.setTagTitle();if(l.nodes.tag&&(l.getOption("useContainer")=="Y"||(!l.popups.main||!l.popups.main.isShown())&&(!l.popups.search||!l.popups.search.isShown()))){e.style(l.nodes.tag,"display","inline-block")}e.onCustomEvent("BX.UI.Selector.Callback:unSelect",[{selectorId:l.id}])};e.UI.Selector.Callback.openDialog=function(t){var n=t.selectorId;if(!n){return}var i=e.UI.SelectorManager.instances[n];if(!e.type.isNotEmptyObject(i)){return}if(i.getOption("multiple")!="Y"&&i.nodes.inputBox){e.style(i.nodes.inputBox,"display","inline-block")}if(i.nodes.tag){e.style(i.nodes.tag,"display","none")}e.defer(e.focus)(i.nodes.input)};e.UI.Selector.Callback.closeDialog=function(t){var n=t.selectorId;if(!n){return}var i=e.UI.SelectorManager.instances[n];if(!e.type.isNotEmptyObject(i)){return}if(!i.isSearchOpen()&&i.nodes.input&&i.nodes.input.value.length<=0){if(i.nodes.inputBox){e.style(i.nodes.inputBox,"display","none")}if(i.nodes.tag&&(i.getOption("multiple")=="Y"||Object.keys(i.itemsSelected).length<=0)){e.style(i.nodes.tag,"display","inline-block")}e.UI.Selector.Callback.disableBackspace()}};e.UI.Selector.Callback.disableBackspace=function(){if(e.type.isFunction(e.UI.Selector.Callback.disableBackspaceHandler)){e.unbind(window,"keydown",e.UI.Selector.Callback.disableBackspaceHandler)}e.bind(window,"keydown",e.UI.Selector.Callback.disableBackspaceHandler=function(t){if(t.keyCode==8&&!e.util.in_array(t.target.tagName.toLowerCase(),["input","textarea"])){t.stopPropagation();t.preventDefault();return false}});setTimeout(function(){e.unbind(window,"keydown",e.UI.Selector.Callback.disableBackspaceHandler);e.UI.Selector.Callback.disableBackspaceHandler=null},5e3)};e.UI.Selector.Callback.getHiddenInputCollection=function(t){var n=[],i=e.type.isNotEmptyString(t.fieldName)?t.fieldName:false,a=e.type.isNotEmptyString(t.entityType)?t.entityType:false,l=e.type.isNotEmptyString(t.itemId)?t.itemId:false;if(!i){return n}n.push(e.create("INPUT",{attrs:{type:"hidden",name:i+(!!t.multiple?"[]":""),value:l}}));return n}})();
//# sourceMappingURL=callback.map.js